/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trefliq.EJB.entities;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Adam Gojdas
 */
@Entity
@Table(name = "MOVIECREDIT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "findAllMovieCredits", query = "SELECT m FROM MovieCredit m"),
    @NamedQuery(name = "findByMovieid", query = "SELECT m FROM MovieCredit m WHERE m.movieCreditPK.movieid = :movieid"),
    @NamedQuery(name = "findByShowbizpeopleid", query = "SELECT m FROM MovieCredit m WHERE m.movieCreditPK.showbizpeopleid = :showbizpeopleid"),
    @NamedQuery(name = "findByCreditid", query = "SELECT m FROM MovieCredit m WHERE m.movieCreditPK.creditid = :creditid"),
    @NamedQuery(name = "findByMovieidShowbizpeopleidCreditid", query = "SELECT m FROM MovieCredit m WHERE  m.movieCreditPK.movieid = :movieid AND m.movieCreditPK.showbizpeopleid = :showbizpeopleid AND m.movieCreditPK.creditid = :creditid")})
public class MovieCredit implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected MovieCreditPK movieCreditPK;
    @JoinColumn(name = "SHOWBIZPEOPLEID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private ShowBizPeople showBizPeople;
    @JoinColumn(name = "MOVIEID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Movie movie;
    @JoinColumn(name = "CREDITID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Credit credit;

    public MovieCredit() {
    }

    public MovieCredit(MovieCreditPK movieCreditPK) {
        this.movieCreditPK = movieCreditPK;
    }

    public MovieCredit(long movieid, long showbizpeopleid, long creditid) {
        this.movieCreditPK = new MovieCreditPK(movieid, showbizpeopleid, creditid);
    }

    public MovieCreditPK getMovieCreditPK() {
        return movieCreditPK;
    }

    public void setMovieCreditPK(MovieCreditPK movieCreditPK) {
        this.movieCreditPK = movieCreditPK;
    }

    public ShowBizPeople getShowBizPeople() {
        return showBizPeople;
    }

    public void setShowBizPeople(ShowBizPeople showBizPeople) {
        this.showBizPeople = showBizPeople;
    }

    public Movie getMovies() {
        return movie;
    }

    public void setMovies(Movie movie) {
        this.movie = movie;
    }

    public Credit getCredit() {
        return credit;
    }

    public void setCredit(Credit credit) {
        this.credit = credit;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (movieCreditPK != null ? movieCreditPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MovieCredit)) {
            return false;
        }
        MovieCredit other = (MovieCredit) object;
        if ((this.movieCreditPK == null && other.movieCreditPK != null) || (this.movieCreditPK != null && !this.movieCreditPK.equals(other.movieCreditPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "se554.grp3.adg.MovieCredit[ movieCreditPK=" + movieCreditPK + " ]";
    }
    
}
